<template>
	<view>
		<!--已经登录状态-->
		<view v-if="userinfo && userinfo.uid!=-1">
			<view class="userinfo-wraper">
				<view class="flex" v-if="userinfo && userinfo.uid!=''">
					<view style="padding: 20px 15px;">
						<u-avatar :src="userinfo.avatar" size="56"></u-avatar>
					</view>
					<view style="flex: 1;">
						<view class="flex pt20">
							<view style="font-weight: bold;font-size: 15px; line-height: 30px;">{{userinfo.nickname}}</view>
						</view>
						<view class="flex" style="color:#888">
							<view>手机号:</view>
							<view>{{userinfo.mobile}}</view>
						</view>
					</view>
				</view>
			</view>
			
			<view style="background-color: #FFF;">
				<u-cell-group>
					<u-cell title="手机号" :value="userinfo.mobile"></u-cell>
					<u-cell title="企业名称" :value="userinfo.suptitle"></u-cell>
				</u-cell-group>
			</view>
			
			<view style="margin-top: 50px;" >
				<u-button @click="handleExit">退出登录</u-button>
			</view>
		</view>
		<!--未登录-->
		<view v-if="userinfo=='' || userinfo==null">
			<view class="userinfo-wraper">
				<view class="flex">
					<view style="padding: 20px 15px;">
						<u-avatar :src="userinfo.avatar" size="56"></u-avatar>
					</view>
					<view style="flex: 1;">
						<view class="flex pt20">
							<view style="font-weight: bold;font-size: 15px; line-height: 30px;">未登录</view>
						</view>
						<view class="flex" style="color:#888">
							<view>手机号:</view>
							<view>-</view>
						</view>
					</view>
				</view>
			</view>
			
			<view style="background-color: #FFF;">
				<u-cell-group>
					<u-cell title="手机号" value="需要登录后显示"></u-cell>
					<u-cell title="企业名称" value="需要登录后显示"></u-cell>
				</u-cell-group>
			</view>
			

		</view>
		
	</view>
</template>

<script>
	import {
		post
	} from '@/utils/request';
	export default {

		data() {
			return {
				userinfo: {
					mobile:'',
					uid:-1,
					supid:-1,
					suptitle:''
				},
			}
		},
		onShow() {
			if (uni.getStorageSync("token") == "") {
				/*uni.navigateTo({
					url:"/pages/login/index"
				})*/
				return;
			}
		},
		mounted() {
			if(uni.getStorageSync("userinfo")!=null){
				this.userinfo=uni.getStorageSync("userinfo");
				console.log(this.userinfo);
			}
		},
		onLoad() {

		},
		methods: {
			handleExit(){
				uni.removeStorageSync("userinfo");
				uni.removeStorageSync("token");
				uni.reLaunch({
					url:"/pages/index/index"
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.pt20 {
		padding-top: 20px;
	}

	.miconstyle {
		margin-bottom: 6px;
		margin-top: 10px;
	}

	.userinfo-wraper {
		background-color: #fff;
		padding: 5px;
	}

	.username {
		font-size: 15px;
		line-height: 30px;
	}

	.camera {
		width: 54px;
		height: 44px;

		&:active {
			background-color: #ededed;
		}
	}

	.user-box {
		background-color: #fff;
	}

	.u-cell-group {
		background-color: #fff;
	}
</style>